package com.blb.demo4;

import com.blb.AMDCpu;
import com.blb.Cpu;
import com.blb.KingStonMemory;
import com.blb.Memory;
import org.springframework.stereotype.Component;

/**
 * @author lvtian
 * @date 2022/12/22 10:14
 */
@Component
public class Computer {
    @MyValue("华为")
    private String brand;

    @MyAutowite(AMDCpu.class)
    private Cpu cpu;


    @MyAutowite(KingStonMemory.class)
    private Memory memory;

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        System.out.println("走set");
        this.brand = brand;
    }

    public Cpu getCpu() {
        return cpu;
    }

    public void setCpu(Cpu cpu) {
        System.out.println("走set");
        this.cpu = cpu;
    }

    public Memory getMemory() {
        return memory;
    }

    public void setMemory(Memory memory) {
        System.out.println("走set");
        this.memory = memory;
    }
    public void run(){
        System.out.println(brand+"品牌的电脑启动了");
        cpu.run();
        memory.read();
        memory.write();
    }

    public Computer(String brand, Cpu cpu, Memory memory) {
        System.out.println("走构造方法");
        this.brand = brand;
        this.cpu = cpu;
        this.memory = memory;
    }

    public Computer() {
        System.out.println("走构造方法");
    }
}
